package a04_字符串;

import java.util.Scanner;

/**
 * <p>
 * a05_右旋字符串
 * </p>
 *
 * @author flyduck
 * @since 2024-07-11
 */
public class a05_右旋字符串复习3 {




    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        String s = scanner.next();
        System.out.println(rightSwap(s, k));
    }

    public static String rightSwap(String str, int n) {
        char[] chars = str.toCharArray();
        reverse(chars, 0, chars.length -1);
        reverse(chars, 0, n - 1);
        reverse(chars, n, chars.length -1);
        return new String(chars);
    }

    public static void reverse(char[] chars,int leftIdx,int rightIdx){
        while (leftIdx < rightIdx) {
            char temp = chars[leftIdx];
            chars[leftIdx] = chars[rightIdx];
            chars[rightIdx] = temp;
            leftIdx++;
            rightIdx--;
        }
    }


}
